package com.tom.architect02.mnbase.zarch;

import java.util.List;

/**迭代器模式：针对List
 *     @Override
 *     public Iterator iterator() {
 *         return new MinIterator(list);
 *     }
 */
public class MinIterator implements Iterator {

    private List<Object> list;
    private int position;

    public MinIterator(List<Object> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        return !(position > list.size() - 1 || list.get(position) == null);
    }

    @Override
    public Object next() {
        Object e = list.get(position);
        position++;
        return e;
    }
}
